import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ScrollingModule } from '@angular/cdk/scrolling';
import { PortalModule } from '@angular/cdk/portal';
import { FormsModule } from '@angular/forms';
import { OverlayModule } from '@angular/cdk/overlay';
import { CheckboxModule } from '../checkbox/api';
import { OverlayService, I18NModule } from '../core/api';
import { SortModule } from '../sort/api';
import { IconModule } from '../icon/api';
import { ButtonModule } from '../button/api';
import { SelectModule } from '../select/api';
import { PopoverModule } from '../popover/api';
import { SearchModule } from '../search/api';
import { TooltipModule } from '../tooltip/api';
import { GroupModule } from '../group/api';
import { EmptyModule } from '../empty/api';
import { VirtualScrollDirective } from './virtual-scroll.directive';
import { DatatableService } from './datatable.service';
import { TbodyDirective } from './tbody.directive';
import { TrComponent } from './tr.component';
import { TreetableComponent } from './treetable.component';
import { TdComponent } from './td.component';
import { ThComponent } from './th.component';
import { TheadComponent } from './thead.component';
import { DatatableComponent } from './datatable.component';
import { ColgroupDirective } from './colgroup.directive';

const COMPONENTS = [DatatableComponent, TheadComponent, TdComponent, ThComponent, TrComponent, TreetableComponent];

const DIRECTIVE = [TbodyDirective, VirtualScrollDirective, ColgroupDirective];

const MODULES = [
  FormsModule,
  ScrollingModule,
  IconModule,
  PortalModule,
  SortModule,
  CheckboxModule,
  OverlayModule,
  ButtonModule,
  I18NModule,
  PopoverModule,
  SearchModule,
  TooltipModule,
  GroupModule,
  EmptyModule,
  SelectModule,
];

@NgModule({
  declarations: [...COMPONENTS, ...DIRECTIVE],
  imports: [CommonModule, ...MODULES],
  exports: [...COMPONENTS, ...DIRECTIVE, SortModule],
  providers: [DatatableService, OverlayService],
})
export class DatatableModule {}
